<?php
/**
 * An order item object (Datamapper)
 *
 * @author Ishtiaque Shahrier <md.ishtiaque@newgenbd.net>
 * @package order
 * @subpackage models
 */
class order_item_m_order extends a_base_model_datamapper {

    public function __construct($id=null) {
        $this->table = 'order_items';
        $this->has_many = array(
        );
        $this->has_one = array(
        );
        $this->has_one['order_m_order'] = array(
            'class' => 'order_m_order',
            'join_other_as' => 'order',
            'join_self_as' => 'item'
        );
        parent::__construct($id);
    }

    public function get_product(){
        $prod = new product_m_product();
        $prod->get_by_part_num($this->part_num);
        if($prod->exists()){
            return $prod;
        }else{
            return NULL;
        }
    }

    public function price_x_qty(){
        return round($this->unit_price * $this->qty ,2 );
    }
}
?>